<?php

	define('SHOW_MOD_SECURITY_WARNING', false);
 
	// Little hack so we can load in header from other places.
	$folder = "./";
	if (isset($folderOverride))
	{
		$folder = $folderOverride;
	}
	
?>
	<link type="text/css" rel="stylesheet" href="<?php echo $folder; ?>swx.css" />
	
	<script type="text/javascript" src="<?php echo $folder; ?>js/swfobject.js"></script>
</head>

<body>

	<div class="headerImage">
		<img src="<?php echo $folder; ?>images/swx_01.jpg" class="topLeftImage" />
		<img src="<?php echo $folder; ?>images/swx_03.png" class="topRightImage" />
	</div>

	<?php
		// The idea is to provide as much feedback, warnings, errors, etc. as possible so that 
		// SWX PHP does not fail silently.
	
		// Run the unit tests so users will know straight away if the SWF assembler
		// works correctly on their machine.
		
		$currentDir = getcwd();
		chdir($folder.'php/tests');
		require_once('all_tests.php');
		chdir($currentDir);
		
		// Run the SWX RPC tests. This tests all supported data types on the SWX PHP endpoint through the RPC interface.
		// (Only run these tests on the main page).
		
		if ($folder == './')
		{
			$divId = "dataTypeTests";
			if (isset($divPrefix)) 
			{
				$divId = $divPrefix . $divId;
			}
	?>
		<div id="<?php echo $divId; ?>">You must have the Flash Player installed to run the SWX tests.</div>

		<script type="text/javascript"> /*<!--*/ var so = new SWFObject("<?php echo $folder; ?>swfs/TestDataTypesForStartPage.swf", "TestDataTypesForStartPage_swf", "100%", "16", "6");  so.write("<?php echo $divId; ?>"); /*-->*/ </script>
	
	<?php	
		}  // end of if.
		
		// Run tests for known incompatibilities (PHP configuration, Apache modules, etc.)
		// and inform the user so things don't fail silently/inexplicably.
		$openBasedir = ini_get('open_basedir');
		$safeMode = ini_get('safe_mode'); 	
		
		// Get PHP INFO without writing it out for the world to see.
		ob_start();
		phpinfo(INFO_MODULES);
		$phpInfo = ob_get_contents();
		ob_end_clean();
		
		$modSecurity = strstr($phpInfo, 'mod_security');
		
		if ($openBasedir) 
		{
			echo '<div class="error"><strong>Warning:</strong> <a href="http://de3.php.net/features.safe-mode#ini.open-basedir" target="_blank">open_basedir is set in PHP.ini</a>. Certain SWX APIs will not work properly with this restriction. Please turn open_basedir off (or contact your web host and ask them to do this for you.) </div>';
		}
		
		if ($safeMode)
		{
			echo '<div class="error"><strong>Warning:</strong> <a href="http://de3.php.net/features.safe-mode" target="_blank">Safe Mode is on in PHP.ini</a>. SWX will not work properly with this restriction. Please turn Safe Mode off (or contact your web host and ask them to do this for you.) </div>';			
		}
		
		if ($modSecurity && SHOW_MOD_SECURITY_WARNING)
		{
			echo '<div class="error"><strong>Warning:</strong> <a href="http://swxformat.org/33/" target="_blank">mod_security is enabled on your server</a>. SWX will not allow cross-domain data exchange with this restriction. Please turn mod_security off (or contact your web host and ask them to do this for you.) <a href="http://swxformat.org/33" target="_blank">Read more about this issue here</a>.</div>';			
			
		}
		
		if (version_compare(PHP_VERSION, "4.4.2", "<"))
		{
			echo '<div class="error"><strong>Warning:</strong> Your version of PHP ('.PHP_VERSION.') is lower than the minimum supported version (4.4.2). SWX PHP will most likely not work on your system. Please see the <a href="http://swxformat.org/documentation/swx-php/#83" target="_blank">SWX PHP minimum system requirements</a>.</div>';						
		}

	?>

	<div class="content">
		<?php require($folder.'navigation.php'); ?>
